home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / GDevice.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  3.8 KB  |  149 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1991 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Originator: Kent Sandvik
  5.   Date: Wednesday, June 3, 1992 10:10:46
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TGDevice is a GDevice utility class, finding out GDevice information.
  9.   GDevice.cp contains the class body information for the TGDevice class.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12. // Include files
  13. #ifndef _GDEVICE_
  14. #include "GDevice.h"
  15. #endif
  16.  
  17.  
  18. // _________________________________________________________________________________________________________ //
  19. // TGDevice class member function implementations
  20.  
  21. //    CONSTRUCTORS & DESTRUCTORS
  22. #pragma segment GDevice                   
  23. TGDevice::TGDevice()
  24. // The default constructor will just call the IGDevice method which will search
  25. // and hopefully find the GDList (if not the fStatus is false in the class).
  26. {
  27.     fFirstTime = true;                            // indicate we are inside the constructor
  28.     fLast = false;                                // no wrap yet (constructor time)
  29.     Boolean fState = this->IGDevice();            // initialize the object
  30.     fFirstTime = false;                            // out, we are no longer in a cvt
  31.     fFirstGDList = fGDList;                        // record the first in the list
  32. }
  33.  
  34.  
  35. #pragma segment GDevice
  36. TGDevice::~TGDevice()
  37. // Destructor, we are not doing anything inside this one just now.
  38. {
  39. }
  40.  
  41.  
  42. //    INITIATION ROUTINES
  43. #pragma segment GDevice
  44. Boolean TGDevice::IGDevice()
  45. // Look for the GDList, return true if found, false if not.
  46. {
  47.  
  48.     if (fFirstTime)                                // first time we are critical about NULL!
  49.     {
  50.         fGDList = ::GetDeviceList();            // get the device list
  51.         ASSERT(fGDList != NULL, "\pGetDeviceList returned NULL");
  52.  
  53.         this->GetGDeviceValues();                // fill in the proper values ASAP
  54.  
  55.         if (fGDList == NULL)                    // we had a problem
  56.             goto IGDeviceFalse;
  57.         else
  58.             goto IGDeviceOK;                    // OK
  59.     }
  60.     else                                        // we are now called from Next, OK with NULL
  61.         {
  62.             fGDList = ::GetNextDevice(fGDList);    // continue the iteration
  63.  
  64.             if (fGDList == NULL)                // beyond the last one?
  65.             {
  66.                 fGDList = fFirstGDList;            // back to the first one
  67.                 fLast = true;                    // signal this was the last one
  68.                 goto IGDeviceOK;
  69.             }
  70.             goto IGDeviceOK;                    // OK anyway!
  71.         }
  72. IGDeviceFalse:return false;
  73. IGDeviceOK:return true;
  74. }
  75.  
  76.  
  77. #pragma segment GDevice                   
  78. void TGDevice::Next()
  79. // Gets the information from the following devices.
  80. {
  81.     this->IGDevice();
  82.     this->GetGDeviceValues();
  83. }
  84.  
  85.  
  86. #pragma segment GDevice                   
  87. void TGDevice::First()
  88. // Reset to the first GDevice we found.
  89. {
  90.     fGDList = fFirstGDList;
  91. }
  92.  
  93.  
  94. #pragma segment GDevice                   
  95. Ptr TGDevice::GetBase() const
  96. // Return the pointer of the GDevice base, not the address (more flexible that way)
  97. {
  98.     return fBase;
  99. }
  100.  
  101.  
  102. #pragma segment GDevice                   
  103. long TGDevice::GetRow() const
  104. // Return row value.
  105. {
  106.     return fRow;
  107. }
  108.  
  109.  
  110. #pragma segment GDevice                   
  111. short TGDevice::GetDepth() const
  112. // Return the depth level of the GDevice.
  113. {
  114.     return fDepth;
  115. }
  116.  
  117.  
  118. #pragma segment GDevice                   
  119. Boolean TGDevice::Last() const
  120. // Just return the Boolean value if this was the last GDevice or not.
  121. {
  122.     return fLast;
  123. }
  124.  
  125.  
  126. //    PRIVATE MEMBER FUNCTIONS
  127. #pragma segment GDevice
  128. void TGDevice::GetGDeviceValues()
  129. // Get the GDevice information from the GDList device
  130. {
  131.     fBase = (*(*fGDList)->gdPMap)->baseAddr;
  132.  
  133.     fRow = (*(*fGDList)->gdPMap)->rowBytes;
  134.     fRow = fRow & 0x0000FFFF;
  135.  
  136.     fDepth = (*(*fGDList)->gdPMap)->pixelSize;
  137.     fDepth = fDepth & 0x0000FFFF;
  138. }
  139.  
  140.  
  141. // _________________________________________________________________________________________________________ //
  142.  
  143. /*    Change History (most recent last):
  144.   No        Init.    Date        Comment
  145.   1            khs        6/2/92        New file
  146.   2            khs        7/5/92        First decent release
  147.   3            khs        9/7/92        More hacking for multi-dev platform use
  148. */
  149.